#ifndef _SMP_SCROLLVIEW_H
#define _SMP_SCROLLVIEW_H

#include "sgl_funcs.h"
#include "sgl_window.h"

enum 
{
	    SMP_SCROLLVIEW_SETFOUCS,
		SMP_SCROLLVIEW_SETVIEWPOS,
		SMP_SCROLLVIEW_GETVIEWPOS,
		SMP_SCROLLVIEW_GETVIEW
		//SMP_SCROLLVIEW_WNDPROC
};

#ifndef SDK_NO_PLUGIN
#define SMP_SCROLLVIEW_WNDPROC  MPS_CODE_SMP_SCROLLVIEW_PROC
#else
#define SMP_SCROLLVIEW_WNDPROC  SMP_ScrollView_WndProc
#endif

/**
  \defgroup smp_scrollview Simple ScrollView

  To work with the simple ScrollView:
	- Create the ScrollView
	- Get the Content view of the ScrollView
	- Add your window to the content view 
	- Set the LISTENER of your window to your top-level windos
  
  \code
	//create a ScrollView
	hScrollView = SGL_CreateWindow(SMP_ScrollView_WndProc, ...);
	hContent = SMP_ScrollView_GetContentView(hScrollView);

	hControl = SGL_CreateWindow("your window", ...);
	_LISTENER(hControl) = hWnd; // should set your listener and the notify message will send to hWnd
	SGL_AddChildWindow(hContent, hControl);

	......
	SGL_AddChildWindow(hWnd, hScrollView);
  \endcode
  
  @ingroup controls
  @{
*/

	/**
	 * \name Window Member Functions
	 * @{
	 */
#if defined(INCLUDE_IN_PLUG_SGL_SRC) || defined(SDK_NO_PLUGIN)
/**
 * \brief Get the scrollview content view
 *
 * For we must add your window to a scrollview's content view not the scrolview itself.
 *
 * \param hWnd the scrollview window handle
 * \return the content view handle
 */
HWND SMP_ScrollView_GetContentView(HWND hWnd);

/**
 * \brief init the focus wnd
 *
 */
int32 SMP_ScrollView_SetFocus(HWND hWnd, HWND hFocus);

/**
 * \brief init the scrollview's postion
 *
 * You'd better use this function after all child have been added,because we 
 * would restrict the param 2 if it is unnormal.
 */
int32 SMP_ScrollView_SetViewPos(HWND hWnd, int nViewPos);

/**
 * \brief get the scrollview's postion
 */
int32 SMP_ScrollView_GetViewPos(HWND hWnd, int *pViewPos);

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief Simple ScrollView window procedure
 *
 * \param hWnd the window handle
 * \param Msg the window message 
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */

LRESULT SMP_ScrollView_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

#else

#define SMP_ScrollView_GetContentView(hWnd) \
	(HWND)mrc_extSendAppEventEx(MPS_CODE_SMP_SCROLLVIEW, SMP_SCROLLVIEW_GETVIEW, (int32)hWnd, (int32)0, (int32)0, (int32)0, (int32)0)

#define SMP_ScrollView_SetFocus(hWnd,hFocus) \
	(VOID)mrc_extSendAppEventEx(MPS_CODE_SMP_SCROLLVIEW, SMP_SCROLLVIEW_SETFOUCS, (int32)hWnd, (int32)hFocus, (int32)0, (int32)0, (int32)0)

#define SMP_ScrollView_SetViewPos(hWnd,nViewPos) \
	(VOID)mrc_extSendAppEventEx(MPS_CODE_SMP_SCROLLVIEW, SMP_SCROLLVIEW_SETVIEWPOS, (int32)hWnd, (int32)nViewPos, (int32)0, (int32)0, (int32)0)

#define SMP_ScrollView_GetViewPos(hWnd,pViewPos) \
	(VOID)mrc_extSendAppEventEx(MPS_CODE_SMP_SCROLLVIEW, SMP_SCROLLVIEW_GETVIEWPOS, (int32)hWnd, (int32)pViewPos, (int32)0, (int32)0, (int32)0)

#define SMP_ScrollView_WndProc(hWnd,Msg,wParam,lParam) \
	(LRESULT)mrc_extSendAppEventEx(MPS_CODE_SMP_SCROLLVIEW, (int32)hWnd, (int32)hWnd, (int32)Msg, (int32)wParam, (int32)lParam, (int32)0)
	/** @} */

/** @} end of smp_scrollview */
#endif

#endif
